<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自增自减</title>
</head>
<body>
    <script>
        /*
        1. 传统写法 
        let num = 5;
        num = num+1;
        console.log(num); */

        //2. 等效于自增运算符
        //自增运算符---后置== 先返回 后加1
        let num = 10;
        console.log(num++ +5);//15
        console.log(num);//11

        //前置---先加1  后返回
        let num1= 10;
        console.log(++num1 +5);//16
        console.log(num1);//11



        //自减运算符
        let age = 10;
        console.log(age-- -5);//5
        console.log(age);//9
        // 前置
        let temp = 10;
        console.log(--temp -5);//4
        console.log(temp);//9

    </script>
</body>
</html>